﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Modeling;
using BizAppFactory.Domain;
using Microsoft.VisualStudio.Modeling.Diagrams;

//namespace x 
//{
//    [RuleOn(typeof(EmbeddingConnector), FireTime = TimeToFire.TopLevelCommit)]
//    public sealed class NavigationDirectionChangeRule : ChangeRule
//    {
//        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
//        {
//            base.ElementPropertyChanged(e);
//            EmbeddingConnector connector = (EmbeddingConnector)e.ModelElement;
//            Embedding embeddingModelElement = (Embedding) connector.ModelElement;

//            switch (embeddingModelElement.NavigationDirection)
//            {
//                case NavigationDirection.Bidirectional:
//                    connector.DecoratorTo = LinkDecorator.DecoratorEmptyArrow;
//                    connector.DecoratorFrom = LinkDecorator.DecoratorEmptyArrow;
//                    break;

//                case NavigationDirection.SourceToTarget:
//                    connector.DecoratorTo = LinkDecorator.DecoratorEmptyArrow;
//                    connector.DecoratorFrom = null;
//                    break;

//                case NavigationDirection.TargetToSource:
//                    connector.DecoratorTo = null;
//                    connector.DecoratorFrom = LinkDecorator.DecoratorEmptyArrow;
//                    break;
//                default:
//                    throw new ApplicationException("Not supported navigation direction");
//            }
//        }
//    }
// }

// Change ExampleRelation and ExampleProperty to your relation and property:
//if (e.MetaAttribute.Id == ExampleRelation.ExamplePropertyMetaAttributeGuid)
//  {
//    foreach (ExampleConnector link in e.ModelElement.AssociatedPresentationElements)
//    {
//      if ((e.NewValue as string).Length > 2)  // or whatever your test should be
//        link.Color = System.Drawing.Color.Blue;
//      else
//        link.Color = System.Drawing.Color.Red;
//    }
//  }
//internal static partial class GeneratedMetaModelTypes
 //{
 // // Each rule should be mentioned in this class.
 // // The variable can be called anything.
 // [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
 //  internal static Type ConnectorColorChangeRule = typeof(ConnectorColorChangeRule);
 //}

